import { PATH_WHITE_LIST } from '@/setting'
import cookies from '@/utils/util.cookies'

export function createPermissionGuard(router) {
  router.beforeEach(async (to, from) => {
    // 白名单的路径直接放过
    if (PATH_WHITE_LIST.includes(to.fullPath)) {
      return true
    }

    // 校验当前账号是否登录
    const token = cookies.get('token')
    if (token) {
      // TODO 权限校验逻辑
    } else {
      return { name: 'login' }
    }
  })
}
